package com.test.designPattern;

//参考文章：http://www.cnblogs.com/xudong-bupt/p/3433643.html
public class Singleton {
    private Singleton() {
        System.out.println("singleton");
    }
    private static class Inner{
        private static Singleton s = new Singleton();
    }
    public static Singleton getSingleton() {
        return Inner.s;
    }

    public static void main(String[] args) {
        Thread[] ths = new Thread[200];
        for (int i = 0; i < ths.length; i++) {
            ths[i] = new Thread(() -> {
                Singleton singleton = Singleton.getSingleton();
                System.out.println(singleton);
                System.out.println("lksjdfl");
            });

            for (Thread th : ths) {
                System.out.println(th);
            }
//            Arrays.asList(ths).forEach(o ->o.start());
        }
    }
}
